package com.hdu.kdk_feign.paramHandler;

import com.hdu.kdk_feign.annotation.PathVariable;

import java.util.ArrayList;
import java.util.List;

public class PathVariableParamHandler implements ParamHandler {


    @Override
    public boolean support(Param param) {
        return param.getParamAnnotation() != null
                &&
                param.getParamAnnotation().annotationType().isAssignableFrom(PathVariable.class);
    }

    @Override
    public void handle(TotalRequestParamInfo totalRequestParamInfo, Param param) {
        List<Object> pathVariables = totalRequestParamInfo.getPathVariables();
        if (pathVariables == null) {
            pathVariables = new ArrayList<>();
            totalRequestParamInfo.setPathVariables(pathVariables);
        }
        pathVariables.add(param.getParamValue());
    }


}
